export const convertTimestampToDate = (timestamp) =>{
    const date = new Date(timestamp); // 注意乘以1000，因为Date对象使用的是毫秒
    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份是从0开始的
    const day = String(date.getDate()).padStart(2, '0');

    return `${year}-${month}-${day}`;
}

//转换为时间错
export const  convertDateToTimestamp =(timestamp) =>{
    const date = new Date(timestamp); // 注意乘以1000，因为Date对象使用的是毫秒
    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份是从0开始的
    const day = String(date.getDate()).padStart(2, '0');
    const hours = String(date.getHours()).padStart(2, '0');
    const minutes = String(date.getMinutes()).padStart(2, '0');
    const seconds = String(date.getSeconds()).padStart(2, '0');

    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
export const uniqueObjectArray=(arr, field) =>{
    const seen = new Set();
    return arr.map(item => {
        const value = item[field];
        if (seen.has(value)) {
            return null; // 或者你可以返回一个特定的值来表示重复
        }
        seen.add(value);
        return item;
    }).filter(item => item !== null); // 过滤掉重复项
}

export function getHourMins(timestamp) {
    let date = new Date(timestamp);
    let hours = date.getHours();
    let minutes = date.getMinutes();
    return hours + ":" + minutes;
  }